package com.aeon.ui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class TableComponent extends Composite {

	private Table mTable;

	public TableComponent(Composite parent, int style) {
		super(parent, style);
		setLayout(new FillLayout());
		setupTable();
	}

	private void setupTable() {
		mTable = new Table(this, SWT.CHECK|SWT.MULTI|SWT.FULL_SELECTION);

		mTable.setHeaderVisible(true);
		mTable.setLinesVisible(true);
		
		createColumn("first", 40);
		createColumn("second", 40);
		createColumn("third", 40);

		createItems( new String[]{"1","2","3"});
		createItems( new String[]{"1","2","3"});
		createItems( new String[]{"1","2","3"});
		
		
	}

	private void createItems( String[] data) {
		TableItem tableItem= new TableItem(mTable, SWT.NONE);
		tableItem.setText(data);
	}

	private void createColumn(String header, int width) {
		TableColumn column=new  TableColumn(mTable, SWT.NONE);
		column.setText(header);
		column.setWidth(width);
	}

}
